﻿using System.IO;

namespace DNFImagePacks2Manager.NPK
{
    public abstract class ImageFile
    {
        public ImageType Type { get; set; }

        public byte[] DataBytes { get; set; } = [];

        public ImageFile(ImageType type)
        {
            Type = type;
        }

        public abstract int GetSize();

        public abstract bool IsCompressed();

        public abstract byte[] GetIndexBytes();

        public static ImageFile ReadImageFile(BinaryReader reader)
        {
            ImageType imageType = new(reader);
            int type = imageType.TypeCode;

            if (type == 0x11)
            {
                return new ImagePointerFile(reader, imageType);
            }

            if (type < 0x11)
            {
                return new ImageBitmapFile(reader, imageType);
            }
            else
            {
                return new ImageDDSFile(reader, imageType);
            }
        }
    }
}
